<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"  label-width="68px">
      <el-form-item label="合同编号" prop="contractNo">
        <el-input
          v-model="queryParams.contractNo"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="协议号" prop="agreementNo">
        <el-input
          v-model="queryParams.agreementNo"
          placeholder="请输入协议号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同名称" prop="characteristicNum">
        <el-input
          v-model="queryParams.characteristicNum"
          placeholder="请输入合同名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="签订时间" prop="signingDate">
        <el-date-picker clearable
          v-model="queryParams.signingDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择签订时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="数量" prop="quantity" v-show="showSearch">
        <el-input
          v-model="queryParams.quantity"
          placeholder="请输入数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计量单位" prop="measurementUnit" v-show="showSearch">
        <el-select
          v-model="queryParams.measurementUnit"
          placeholder="请选择计量单位"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_measurement_unit"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
     <!-- <el-form-item label="单价" prop="price">
        <el-input
          v-model="queryParams.price"
          placeholder="请输入单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="金额" prop="money">
        <el-input
          v-model="queryParams.money"
          placeholder="请输入金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交付时间" prop="deliveryTime">
        <el-date-picker clearable
          v-model="queryParams.deliveryTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择交付时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="交付进度" prop="deliverySchedule">
        <el-input
          v-model="queryParams.deliverySchedule"
          placeholder="请输入交付进度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="全部交付时间" prop="allDeliveryTime">
        <el-date-picker clearable
          v-model="queryParams.allDeliveryTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择全部交付时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="合同总金额" prop="totalContractAmount">
        <el-input
          v-model="queryParams.totalContractAmount"
          placeholder="请输入合同总金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="责任人" prop="personLiable">
        <el-input
          v-model="queryParams.personLiable"
          placeholder="请输入责任人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="任务ID" prop="taskId">
        <el-input
          v-model="queryParams.taskId"
          placeholder="请输入任务ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <br/>
      <div style="text-align: right;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </div>
      <br/>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!--<el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['module:cjl:second:add']"
        >新增</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['module:cjl:second:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['module:cjl:second:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="secondList"  border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" width="55" :index="indexMethod" align="center" />
      <el-table-column label="协议号" align="center" prop="agreementNo" v-if="columns[0].visible"/>
      <el-table-column label="合同编号" align="center" prop="contractNo" v-if="columns[1].visible"/>
      <el-table-column label="合同名称" align="center" prop="characteristicNum" v-if="columns[2].visible"/>
      <el-table-column label="签订时间" align="center" prop="signingDate" width="180" v-if="columns[3].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signingDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
     <el-table-column label="合同匹配产品类型" align="center" prop="productType" v-if="columns[4].visible"/>
      <el-table-column label="合同匹配零件类型" align="center" prop="partType" v-if="columns[5].visible"/>
      <el-table-column label="数量" align="center" prop="quantity" v-if="columns[6].visible"/>
      <el-table-column label="计量单位" align="center" prop="measurementUnit" v-if="columns[7].visible">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.yh_measurement_unit" :value="scope.row.measurementUnit"/>
      </template>
      </el-table-column>
      <el-table-column label="单价" align="center" prop="price" v-if="columns[8].visible"/>
      <el-table-column label="金额" align="center" prop="money" v-if="columns[9].visible"/>
      <el-table-column label="交付进度" align="center" prop="deliverySchedule" v-if="columns[10].visible"/>
      <el-table-column label="全部交付时间" align="center" prop="allDeliveryTime" width="180" v-if="columns[11].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.allDeliveryTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同总金额" align="center" prop="totalContractAmount" v-if="columns[12].visible"/>
      <el-table-column label="责任人" align="center" prop="personLiable" v-if="columns[13].visible"/>
      <el-table-column label="任务ID" align="center" prop="taskId" v-if="columns[14].visible"/>
      <el-table-column label="备注" align="center" prop="remark" v-if="columns[15].visible"/>
      <el-table-column label="合同关联号" align="center" prop="batchNum" v-if="columns[16].visible"/>
      <el-table-column label="操作" align="center"  width="160" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['module:cjl:second:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            v-hasPermi="['module:cjl:second:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row,scope.index)"
            v-hasPermi="['module:cjl:second:view']"
          >详细</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleTask(scope.row,scope.index)"
            v-hasPermi="['module:cjl:second:task']"
          >任务概览</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <!-- 添加或修改合同对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">监管任务基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <!--<el-col :span="8">
                <el-form-item label="合同关联号" prop="batchNum">
                  <el-input v-model="form.batchNum" readonly="true" />
                </el-form-item>
              </el-col>-->
              <el-col :span="8">
                <el-form-item label="合同编号" prop="contractNo">
                  <el-input v-model="form.contractNo"  readonly="true" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="责任人" prop="personLiable">
                  <el-input v-model="form.personLiable"  readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="数量" prop="quantity">
                  <el-input-number v-model="form.quantity" controls-position="right" :min="0" style="width: 100%" disabled="true"/>
                  <!--  <el-input v-model="form.quantity" placeholder="请输入数量" readonly="true"/>-->
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="任务ID" prop="taskId">
                  <el-input v-model="form.taskId"  readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">产品零件信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="8">
                <el-form-item label="合同匹配产品类型" prop="productType">
                  <el-select v-model="form.productType" multiple placeholder="请选择合同匹配产品类型" style="width: 100%">
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                 <!-- <el-input v-model="form.productType" placeholder="请输入合同匹配产品类型" />-->
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="合同匹配零件类型" prop="partType">
                  <el-select v-model="form.partType" multiple placeholder="请选择合同匹配零件类型" style="width: 100%">
                    <el-option
                      v-for="item in partoptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  <!--<el-input v-model="form.partType" placeholder="请输入合同匹配零件类型" />-->
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">合同台账基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="8">
                <el-form-item label="协议号" prop="agreementNo">
                  <el-input v-model="form.agreementNo" placeholder="请输入协议号"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="合同名称" prop="characteristicNum">
                  <el-input v-model="form.characteristicNum" placeholder="请输入合同名称"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="计量单位" prop="measurementUnit">
                  <el-select v-model="form.measurementUnit" placeholder="请选择计量单位" style="width: 100%"  clearable>
                    <el-option
                      v-for="dict in dict.type.yh_measurement_unit"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                  <!--<el-input v-model="form.measurementUnit" placeholder="请输入计量单位" />-->
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="单价" prop="price">
                  <el-input v-model="form.price" placeholder="请输入单价"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="金额" prop="money">
                  <el-input v-model="form.money" placeholder="请输入金额"  clearable @input="inputNum">
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px;">万元</i>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="交付进度" prop="deliverySchedule">
                  <el-input v-model="form.deliverySchedule" placeholder="请输入交付进度"  clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="全部交付时间" prop="allDeliveryTime">
                  <el-date-picker clearable
                                  v-model="form.allDeliveryTime"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  style="width: 100%"
                                  placeholder="请选择全部交付时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="合同总金额" prop="totalContractAmount">
                  <el-input v-model="form.totalContractAmount" placeholder="请输入合同总金额" clearable @input="inputAmount" >
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px;">万元</i>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="签订时间" prop="signingDate">
                  <el-date-picker clearable
                                  v-model="form.signingDate"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  style="width: 100%"
                                  placeholder="请选择签订时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="备注" prop="note1">
              <el-input v-model="form.note1" type="textarea" placeholder="请输入备注"  maxlength="1000"/>
            </el-form-item>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改合同对话框 -->
    <!--<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="协议号" prop="agreementNo">
          <el-input v-model="form.agreementNo" placeholder="请输入协议号" />
        </el-form-item>
        <el-form-item label="合同编号" prop="characteristicNum">
          <el-input v-model="form.characteristicNum" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同关联号" prop="batchNum">
          <el-input v-model="form.batchNum" placeholder="请输入合同关联号" />
        </el-form-item>
        <el-form-item label="合同名称" prop="contractNo">
          <el-input v-model="form.contractNo" placeholder="请输入合同名称" />
        </el-form-item>
        <el-form-item label="签订时间" prop="signingDate">
          <el-date-picker clearable
            v-model="form.signingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择签订时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input v-model="form.quantity" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="计量单位" prop="measurementUnit">
          <el-input v-model="form.measurementUnit" placeholder="请输入计量单位" />
        </el-form-item>
        <el-form-item label="单价" prop="price">
          <el-input v-model="form.price" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="金额" prop="money">
          <el-input v-model="form.money" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="交付时间" prop="deliveryTime">
          <el-date-picker clearable
            v-model="form.deliveryTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择交付时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="交付进度" prop="deliverySchedule">
          <el-input v-model="form.deliverySchedule" placeholder="请输入交付进度" />
        </el-form-item>
        <el-form-item label="全部交付时间" prop="allDeliveryTime">
          <el-date-picker clearable
            v-model="form.allDeliveryTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择全部交付时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合同总金额" prop="totalContractAmount">
          <el-input v-model="form.totalContractAmount" placeholder="请输入合同总金额" />
        </el-form-item>
        <el-form-item label="责任人" prop="personLiable">
          <el-input v-model="form.personLiable" placeholder="请输入责任人" />
        </el-form-item>
        <el-form-item label="任务ID" prop="taskId">
          <el-input v-model="form.taskId" placeholder="请输入任务ID" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>-->
  </div>
</template>

<script>
import { listSecond, getSecond, delSecond, addSecond, updateSecond } from "@/api/module/cjl/second";
import { listProduct} from "@/api/module/gs/product/product";
import watermark from "watermark-dom";
export default {
  name: "Second",
  dicts: ['yh_measurement_unit'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 合同表格数据
      secondList: [],
      //产品类型选项
      options: [],
      //零件类型选项
      partoptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        agreementNo: null,
        characteristicNum: null,
        batchNum: null,
        contractNo: null,
        signingDate: null,
        productType: null,
        partType: null,
        quantity: null,
        measurementUnit: null,
        price: null,
        money: null,
        deliveryTime: null,
        deliverySchedule: null,
        allDeliveryTime: null,
        totalContractAmount: null,
        personLiable: null,
        taskId: null,
        userId: null,
        deptId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null,
        orderByColumn:"createTime",
        isAsc:"desc"
      },
      // 表单参数
      form: {money:'',totalContractAmount:''},
      // 列信息
      columns: [
        { key: 0, label: `协议号`, visible: true },
        { key: 1, label: `合同编号`, visible: true },
        { key: 2, label: `合同名称`, visible: true },
        { key: 3, label: `签订时间`, visible: true },
        { key: 4, label: `合同匹配产品类型`, visible: false },
        { key: 5, label: `合同匹配零件类型`, visible: false },
        { key: 6, label: `数量`, visible: true },
        { key: 7, label: `计量单位`, visible: true },
        { key: 8, label: `单价`, visible: false },
        { key: 9, label: `金额`, visible: false },
        { key: 10, label: `交付进度`, visible: false },
        { key: 11, label: `全部交付时间`, visible: false },
        { key: 12, label: `合同总金额`, visible: false },
        { key: 13, label: `责任人`, visible: false },
        { key: 14, label: `任务ID`, visible: false },
        { key: 15, label: `备注`, visible: false },
        { key: 16, label: `合同关联号`, visible: false },
      ],
      // 表单校验
      rules: {
        agreementNo: [
          { required: true, message: "协议号不能为空", trigger: "blur" },
        ],
        characteristicNum: [
          { required: true, message: "合同名称不能为空", trigger: "blur" },
        ],
       money: [
          { required: true, message: '请输入金额', trigger: 'blur' },
          { pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/, message: '请输入正确金额格式,可保留六位小数' },
       ],
        totalContractAmount: [
          { required: true, message: '请输入合同总金额', trigger: 'blur' },
          { pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/, message: '请输入正确合同总金额格式,可保留六位小数' },
        ],

      }
    };
  },
  mounted() {
    watermark.load({ watermark_txt: "  "   });
  },
  created() {
    this.getList();
    this.getProduct();
    this.getProduct1();
  },
  methods: {
    inputNum(){
      let price = this.form.money
      let pArr = price.split('.') //得到的是数组,pArr[0]为整数部分,pArr[1]为小数部分
      if(pArr.length > 1) {
        this.form.money = pArr[0] + "." + pArr[1].substr(0, 6);
      }
    },
    inputAmount(){
      let price = this.form.totalContractAmount
      let pArr = price.split('.') //得到的是数组,pArr[0]为整数部分,pArr[1]为小数部分
      if(pArr.length > 1) {
        this.form.totalContractAmount = pArr[0] + "." + pArr[1].substr(0, 6);
      }
    },
    //下拉列表获取所有产品信息
    getProduct() {
      listProduct().then(response => {
        let data = response.rows;
        for (let i = 0; i < data.length; i++) {
          if (data[i].differentiateStates == '0') {
            this.options.push({
              value: data[i].productType,
              label: data[i].productType,
            })
          }
        }
      });
    },
    //下拉列表获取所有零件信息
    getProduct1() {
      listProduct().then(response => {
        let data = response.rows;
        for (let i = 0; i < data.length; i++) {
          if (data[i].differentiateStates == '1') {
            this.partoptions.push({
              value: data[i].partType,
              label: data[i].partType,
            })
          }
        }
      });
    },
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index
    },
    /** 查询合同列表 */
    getList() {
      this.loading = true;
      listSecond(this.queryParams).then(response => {
        this.secondList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        agreementNo: null,
        characteristicNum: null,
        batchNum: null,
        contractNo: null,
        signingDate: null,
        productType: null,
        partType: null,
        quantity: null,
        measurementUnit: null,
        price: null,
        money: null,
        deliveryTime: null,
        deliverySchedule: null,
        allDeliveryTime: null,
        totalContractAmount: null,
        personLiable: null,
        taskId: null,
        userId: null,
        deptId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.is=selection.map(item => item.batchNum)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加合同台账";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getSecond(id).then(response => {
        this.form = response.data;
        let dataIntArr=[];
        //多级选择器回显 ,先转换成String类型的数组，再转换成整型
        let data = response.data.productType
        //如果不为空，则进行处理
        if(data !=null){
          dataIntArr.push(data);
          this.form.productType = dataIntArr
        }
        let dataIntArr1=[];
        //多级选择器回显 ,先转换成String类型的数组，再转换成整型
        let data1 = response.data.partType
        //如果不为空，则进行处理
        if(data1 !=null){
          dataIntArr1.push(data1);
          this.form.partType = dataIntArr1
        }
        this.open = true;
        this.title = "修改合同台账";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            //后台接收的数据是string类型，前台传值需要把数组类型的数据转换成string类型
            if(this.form.productType!= undefined){
              this.form.productType = this.form.productType.toString()
            }
            //后台接收的数据是string类型，前台传值需要把数组类型的数据转换成string类型
            if(this.form.partType!= undefined){
              this.form.partType = this.form.partType.toString()
            }
            updateSecond(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            //后台接收的数据是string类型，前台传值需要把数组类型的数据转换成string类型
            if(this.form.productType!= undefined){
              this.form.productType = this.form.productType.toString()
            }
            //后台接收的数据是string类型，前台传值需要把数组类型的数据转换成string类型
            if(this.form.partType!= undefined){
              this.form.partType = this.form.partType.toString()
            }
            addSecond(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 详细按钮操作 */
    handleView(row) {
      /*const id = row.id || this.ids
      getContract(id).then(response => {
        this.form = response.data;
        this.view.open = true;
        this.view.title = "查看合同台账信息";
      });*/
      const id = row.id;
      this.$router.push({ path:"/hetong/second_detail", query: {id}});
    },
    /** 任务概览按钮操作 */
    handleTask(row) {
      const id = row.taskId;
      let type=row.productType;
      this.$router.push({ path:"/hetong/task_detail", query: {id,type}});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const i=row.batchNum || this.is;
      this.$modal.confirm('是否确认删除合同关联号为"' + i + '"的数据项？').then(function() {
        return delSecond(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('module/cjl/second/export', {
        ...this.queryParams
      }, `second_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>
  .el-header, .el-footer {
    background-color: #FFFFFF;
    color: #333;
    text-align: left;
    line-height: 60px;
    font-style: oblique;

  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }
  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  /*对话框标题样式*/
  .el-dialog__title{
    /*color: #1ab394;*/
    font-weight: bold;
    font-size: 25px;
  }
</style>
